package parser;

import java.util.Properties;

import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;

public class StanfordPipeline extends ParserPipeline {
	private StanfordCoreNLP pipeline;

	/**
	 * @param args
	 *            Comma delimited containing any/all of: tokenize, ssplit, pos,
	 *            lemma, parse
	 */
	public StanfordPipeline(String args, String regexfile) {
		Properties prop = new Properties();
		prop.put("annotators", args);
		if (args.contains("regexner")) {
			prop.put("regexner.mapping", regexfile);
			prop.put("regexner.ignorecase", "true");
		}
		if (args.matches(".*, ?ner.*")) {
//			prop.put("ner.model.3class", "");
			prop.put("ner.model.7class", "");
			prop.put("ner.model.MISCclass", "");
		}
		pipeline = new StanfordCoreNLP(prop);
	}

	@Override
	public ParserAnnotation make(String document) {
		return new StanfordAnnotation(this, document);
	}

	public synchronized Annotation process(String document) {
		return pipeline.process(document);
	}
}
